package com.headStorm.hutooluse;
import cn.hutool.bloomfilter.bitMap.BitMap;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.lang.tree.Tree;
import cn.hutool.core.lang.tree.TreeUtil;
import cn.hutool.core.text.StrFormatter;
import cn.hutool.core.util.ByteUtil;
import cn.hutool.core.util.HexUtil;
import cn.hutool.http.HttpResource;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONArray;
import org.apache.xmlgraphics.util.DoubleFormatUtil;

import java.beans.BeanInfo;
import java.io.UnsupportedEncodingException;
import java.nio.ByteOrder;

/**
 * @author zhangqq
 * @create 2021-07-20 16:01
 **/
public class ConvertDemo {
    public static void main(String[] args) {
//        String str1 = Convert.digitToChinese(1222.4211);
//        System.out.println(str1);
        try {
            test1();
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }

        //通常使用
        String result1 = StrFormatter.format("this is {} for {}", "a", "b");
        System.out.println(result1);

    }


    public static void test1() throws UnsupportedEncodingException {
        byte[] bytes = "你好zhangqq".getBytes("utf-8");
        for (int i = 0; i < bytes.length; i++) {
            System.out.print(bytes[i] + " ");
        }
        System.out.println();

        String headerString = "00 " + HexUtil.format(Convert.toHex(ByteUtil.intToBytes(bytes.length, ByteOrder.BIG_ENDIAN)));
        System.out.println("headerString: " + headerString);
        String bodyHexString = HexUtil.format(Convert.toHex(bytes));
        System.out.println("bodyHexString: " + bodyHexString);
        System.out.println(headerString + " " + bodyHexString);

        byte[] bytes1 = HexUtil.decodeHex("00 00");
        System.out.println(bytes1.length);

        int i = Integer.parseInt("EC78", 16);
        System.out.println(i);


        //System.out.println(Convert.bytesToInt(Convert.hexToBytes("B2")));
    }
}
